package com.xingzhengfan.eurekaclient;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Component
public class MQProducer {
    @Resource(name = "amqpTemplate")
    private RabbitTemplate rabbitTemplate;

    public void sendDataToQueue(MQConfig mqConfig) {
        try {
            rabbitTemplate.convertAndSend(mqConfig.getExchange(), mqConfig.getQueue(), mqConfig.getInfo());
        } catch (AmqpException e) {
            e.printStackTrace();
        }
        System.out.println("send success!!");
    }
}
